import fetch from '../service'

// 定义这一层的原因是接口复用的时候比较方便
export function getCartList(data: { userid: string }) {
  return fetch.request({
    url: "/cart/list",
    method: 'post',
    data
  })
}

// 加入购物车
export function cartAdd(data: { userid: string, proid: string, num: number }) {
  return fetch.request({
    url: "/cart/add",
    method: 'post',
    data
  })
}

// 购物车删除商品
export function cartRemove(data: {
  cartid: string
}) {
  return fetch.request({
    url: "/cart/remove",
    method: 'post',
    data
  })
}

// 更新购物车商品数量
export function cartUpdatenum(data: {
  cartid: string,
  num: number
}) {
  return fetch.request({
    url: "/cart/updatenum",
    method: 'post',
    data
  })
}

// 更新单个商品选中状态
export function cartUpdateSelectone(data: {
  cartid: string,
  flag: boolean,
}) {
  return fetch.request({
    url: "/cart/selectone",
    method: 'post',
    data
  })
}

// 更新全部商品选中状态
export function cartUpdateSelectall(data: {
  userid: string,
  type: boolean
}) {
  return fetch.request({
    url: "/cart/selectall",
    method: 'post',
    data
  })
}

// 猜你喜欢列表数据
export function cartGetRecommendlist(data: { count: number }) {
  return fetch.request({
    url: "/pro/recommendlist",
    method: 'get',
    params: {
      ...data
    }
  })
}